﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace XNA_Game_Framework
{
	public class TileImage : Image
	{
		Vector2 dimensions;

		public override Vector2 Size
		{
			get
			{
				return new Vector2(dimensions.X * image.Width, dimensions.Y * image.Height);
			}
		}

		public TileImage(Control parent, string name, Vector2 position, Texture2D image, Vector2 area)
			: base(parent, name, position, image)
		{
			dimensions = new Vector2(area.X / image.Width, area.Y / image.Height);
		}

		internal override void Draw(SpriteBatch spriteBatch)
		{
			Vector2 position = WindowPosition;
			for (int i = 0; i < dimensions.Y; i++)
			{
				position.X = WindowPosition.X;
				for (int j = 0; j < dimensions.X; j++)
				{
					spriteBatch.Draw(image, position, Color.White);
					position.X += image.Width;
				}
				position.Y += image.Height;
			}
		}
	}
}
